<%
# Copyright (C) 2015 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
%>

<% debugging = presenter.saml_debugging? %>
<div class="debugging">
  <h2 style="margin-top: 10px">
    {{#t}}SAML Debugging{{/t}}
  </h2>

  <div id="saml_debug_console">
    <p>
      <%= t 'saml_debug_instructions', <<-TEXT
          Once you start debugging all info about the next attempted SAML login attempt
          will be collected. Click "Refresh" to see if more data has been collected or
          "Stop Debugging" to clear the collected data and stop the current debug attempt.
          TEXT
       %>
    </p>
    <p>
      <a href="<%= account_saml_testing_url(account) %>"
         id="start_saml_debugging"
         class="btn"
         style="<%= hidden(!debugging) %>">
        {{#t}}Start Debugging{{/t}}
      </a>
      <a href="<%= account_saml_testing_url(account) %>"
         id="refresh_saml_debugging"
         class="btn"
         style="<%= hidden(debugging) %>">
        {{#t}}Refresh{{/t}}
      </a>
      <a href="<%= account_saml_testing_stop_url(account) %>"
         id="stop_saml_debugging"
         class="btn"
         style="<%= hidden(debugging) %>">
        {{#t}}Stop Debugging{{/t}}
      </a>
    </p>

    <div id="saml_debug_info" style="<%= hidden(debugging) %>">
      <% if debugging %>
        <% if presenter.saml_configs.size <= 0 %>
          {{#t}}A SAML configuration is required to test SAML{{/t}}
        <% else %>
          <% presenter.saml_configs.each do |config| %>
            <%= render partial: 'saml_testing',
                       locals: { config: config } %>
          <% end %>
        <% end %>
      <% end %>
    </div>
  </div>
</div>
